home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / shells / tcshsrc.zoo / tcsh / tc.sig.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-11-09  |  6.2 KB  |  189 lines

  1. /* $Header: /home/hyperion/mu/christos/src/sys/tcsh-6.00/RCS/tc.sig.h,v 3.1 1991/07/18 16:20:56 christos Exp $ */
  2. /*
  3.  * tc.sig.h: Signal handling
  4.  *
  5.  */
  6. /*-
  7.  * Copyright (c) 1980, 1991 The Regents of the University of California.
  8.  * All rights reserved.
  9.  *
  10.  * Redistribution and use in source and binary forms, with or without
  11.  * modification, are permitted provided that the following conditions
  12.  * are met:
  13.  * 1. Redistributions of source code must retain the above copyright
  14.  *    notice, this list of conditions and the following disclaimer.
  15.  * 2. Redistributions in binary form must reproduce the above copyright
  16.  *    notice, this list of conditions and the following disclaimer in the
  17.  *    documentation and/or other materials provided with the distribution.
  18.  * 3. All advertising materials mentioning features or use of this software
  19.  *    must display the following acknowledgement:
  20.  *    This product includes software developed by the University of
  21.  *    California, Berkeley and its contributors.
  22.  * 4. Neither the name of the University nor the names of its contributors
  23.  *    may be used to endorse or promote products derived from this software
  24.  *    without specific prior written permission.
  25.  *
  26.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  27.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  28.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  29.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  30.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  31.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  32.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  33.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  34.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  35.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  36.  * SUCH DAMAGE.
  37.  */
  38. #ifndef _h_tc_sig
  39. #define _h_tc_sig
  40.  
  41. #if SVID > 0
  42. # include <signal.h>
  43. # ifndef SIGCHLD
  44. #  define SIGCHLD SIGCLD
  45. # endif                /* SIGCHLD */
  46. #else                /* SVID == 0 */
  47. # include <sys/signal.h>
  48. #endif                /* SVID > 0 */
  49.  
  50. #ifdef sun
  51. # define SAVESIGVEC
  52. #endif
  53.  
  54. #ifdef BSDSIGS
  55. /*
  56.  * sigvec is not the same everywhere
  57.  */
  58. # ifdef _SEQUENT_
  59. #  define HAVE_SIGVEC
  60. #  define mysigvec(a, b, c)    sigaction(a, b, c)
  61. typedef struct sigaction sigvec_t;
  62. #  define sv_handler sa_handler
  63. # endif    /* _SEQUENT */
  64.  
  65. # ifdef __MINT__
  66. #  define HAVE_SIGVEC
  67. typedef struct sigvec {
  68.     sigret_t (*sv_handler)();
  69. } sigvec_t;
  70. extern void mysigvec(int, sigvec_t *, sigvec_t *);
  71. #endif /* __MINT__ */
  72.  
  73. # ifdef hpux
  74. #  define HAVE_SIGVEC
  75. #  define mysigvec(a, b, c)    sigvector(a, b, c)
  76. #  define NEEDsignal
  77. typedef struct sigvec sigvec_t;
  78. # endif    /* hpux */
  79.  
  80. # ifndef HAVE_SIGVEC
  81. #  define mysigvec(a, b, c)    sigvec(a, b, c)
  82. typedef struct sigvec sigvec_t;
  83. # endif    /* HAVE_SIGVEC */
  84.  
  85. # undef HAVE_SIGVEC
  86. #endif /* BSDSIGS */
  87.  
  88. #if SVID > 0
  89. # ifdef BSDJOBS
  90. /* here I assume that systems that have bsdjobs implement the
  91.  * the setpgrp call correctly. Otherwise defining this would
  92.  * work, but it would kill the world, because all the setpgrp
  93.  * code is the the part defined when BSDJOBS are defined
  94.  * NOTE: we don't want killpg(a, b) == kill(-getpgrp(a), b)
  95.  * cause process a might be already dead and getpgrp would fail
  96.  */
  97. #  define killpg(a, b) kill(-(a), (b))
  98. # else
  99. /* this is the poor man's version of killpg()! Just kill the
  100.  * current process and don't worry about the rest. Someday
  101.  * I hope I get to fix that.
  102.  */
  103. #  define killpg(a, b) kill((a), (b))
  104. # endif    /* BSDJOBS */
  105. #endif /* SVID > 0 */
  106.  
  107.  
  108. #ifdef BSDSIGS
  109. /*
  110.  * For 4.2bsd signals.
  111.  */
  112. #ifndef __MINT__
  113. # ifdef sigmask
  114. #  undef sigmask
  115. # endif                /* sigmask */
  116. # define    sigmask(s)    (1 << ((s)-1))
  117. #endif /* __MINT__ */
  118. # ifdef _SEQUENT_
  119. #  define     sigpause(a)    bsd_sigpause(a)
  120. #  define     signal(a, b)    sigset(a, b)
  121. # else /* _SEQUENT_ */
  122. #  define    sighold(s)    sigblock(sigmask(s))
  123. #  define    sigignore(s)    signal(s, SIG_IGN)
  124. #  define     sigset(s, a)    signal(s, a)
  125. # endif    /* _SEQUENT_ */
  126. # ifdef aiws
  127. #  define     sigrelse(a)    sigsetmask(sigblock(0) & ~sigmask(a))
  128. #  undef    killpg
  129. #  define     killpg(a, b)    kill(-getpgrp(a), b)
  130. #  define    NEEDsignal
  131. # endif    /* aiws */
  132. #endif /* BSDSIGS */
  133.  
  134.  
  135. /*
  136.  * We choose a define for the window signal if it exists..
  137.  */
  138. #ifdef SIGWINCH
  139. # define SIG_WINDOW SIGWINCH
  140. #else
  141. # ifdef SIGWINDOW
  142. #  define SIG_WINDOW SIGWINDOW
  143. # endif    /* SIGWINDOW */
  144. #endif /* SIGWINCH */
  145.  
  146. #if defined(convex) || defined(__convex__)
  147. # define SIGSYNCH       0
  148. # ifdef SIGSYNCH
  149. #  define SYNCHMASK     (sigmask(SIGCHLD)|sigmask(SIGSYNCH))
  150. # else
  151. #  define SYNCHMASK     (sigmask(SIGCHLD))
  152. # endif
  153. extern sigret_t synch_handler();
  154. #endif /* convex || __convex__ */
  155.  
  156. #ifdef SAVESIGVEC
  157. # define NSIGSAVED 7
  158.  /*
  159.   * These are not inline for speed. gcc -traditional -O on the sparc ignores
  160.   * the fact that vfork() corrupts the registers. Calling a routine is not
  161.   * nice, since it can make the compiler put some things that we want saved
  162.   * into registers                 - christos
  163.   */
  164. # define savesigvec(sv)                        \
  165.    (mysigvec(SIGINT,  (sigvec_t *) 0, &(sv)[0]),        \
  166.     mysigvec(SIGQUIT, (sigvec_t *) 0, &(sv)[1]),        \
  167.     mysigvec(SIGTSTP, (sigvec_t *) 0, &(sv)[2]),        \
  168.     mysigvec(SIGTTIN, (sigvec_t *) 0, &(sv)[3]),        \
  169.     mysigvec(SIGTTOU, (sigvec_t *) 0, &(sv)[4]),        \
  170.     mysigvec(SIGTERM, (sigvec_t *) 0, &(sv)[5]),        \
  171.     mysigvec(SIGHUP,  (sigvec_t *) 0, &(sv)[6]),        \
  172.     sigblock(sigmask(SIGINT) | sigmask(SIGQUIT) |         \
  173.         sigmask(SIGTSTP) | sigmask(SIGTTIN) |         \
  174.         sigmask(SIGTTOU) | sigmask(SIGTERM) |        \
  175.         sigmask(SIGHUP)))
  176.  
  177. # define restoresigvec(sv, sm)                    \
  178.     (void) (mysigvec(SIGINT,  &(sv)[0], (sigvec_t *) 0),    \
  179.         mysigvec(SIGQUIT, &(sv)[1], (sigvec_t *) 0),    \
  180.         mysigvec(SIGTSTP, &(sv)[2], (sigvec_t *) 0),    \
  181.         mysigvec(SIGTTIN, &(sv)[3], (sigvec_t *) 0),    \
  182.         mysigvec(SIGTTOU, &(sv)[4], (sigvec_t *) 0),    \
  183.         mysigvec(SIGTERM, &(sv)[5], (sigvec_t *) 0),    \
  184.         mysigvec(SIGHUP,  &(sv)[6], (sigvec_t *) 0),    \
  185.         sigsetmask(sm))
  186. # endif                /* SAVESIGVEC */
  187.  
  188. #endif                /* _h_tc_sig */
  189.